package com.jlz.actions.console.column;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Standard;
import org.springframework.beans.factory.annotation.Autowired;

import com.jlz.beans.core.CategoryBean;
import com.jlz.beans.def.ColumnBean;
import com.jlz.managers.core.Categories;
import com.jlz.managers.def.Columns;

@Standard(rest={"id", "type"})
public class IndexAction {
	@Autowired Categories categories;
	@Autowired Columns columns;
	private ColumnBean column = null; 
	private Long id = null;
	private Integer type = null;
	//
	public String execute(){
		column = columns.get(id);
		return "edit";
	}
	
	@Action("create")
	public String create(){
		CategoryBean cate = categories.get(id);
		column = columns.insert(cate);
		column.setType(type);
		column.setIdx(cate.getTableOf(type).getColumns().size());
		return "edit";
	}
	
	//
	public ColumnBean getColumn() {
		return column;
	}
	public void setColumn(ColumnBean column) {
		this.column = column;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getType() {
		return type;
	}

	
	
	
}
